package left42dead;

/**
 * Represents a abstract weapon item
 */
public abstract class Weapon extends Item
{
    // Ammo count
    protected int ammo;
    
    /**
     * Create a weapon with the given ammo
     * @param ammo Initial ammo count
     */
    public Weapon (int ammo)
    {
    	this.ammo = ammo;
    }
    
    /**
     * Reload the weapon with new ammo
     * @return The new ammo count
     */
    public void reload (Ammo ammo) {}
    
    /**
     * Use this weapon and returns the new ammo count
     * @return The new ammo count
     */
    public abstract void use (Character target);

    /**
     * @return true if the weapon is out of ammo, false otherwise
     */
    public boolean isOutOfAmmo ()
    {
        return (getAmmo() <= 0);
    }
    
    // Accessors and getters
    public int getAmmo ()
    {
        return ammo;
    }
    
    public void setAmmo (int ammo)
    {
    	if (ammo > 0) this.ammo = ammo;
    	else this.ammo = 0;
    }
}
